package com.xz.knowledgeDuplication.pattern.iterator;

import java.util.ArrayList;
import java.util.List;

/**
 * 具体聚合角色
 *
 * @author 召
 * @date 2022-03-29 20:59:30
 */
public class AggregateImpl<T> implements Aggregate<T>{

    List<T> list = new ArrayList<T>();

    @Override
    public void add(T object) {
        list.add(object);
    }

    @Override
    public void remove(T object) {
        list.remove(object);
    }

    @Override
    public Iterator<T> getIterator() {
        return new IteratorImpl<T>(list);
    }
}
